<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('property', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('user_id')->index()->default(0)->comment('用户ID');
            $table->string('name', 128)->default('')->comment('资产名称');
            $table->unsignedTinyInteger('status')->default(0)->comment('资产状态');
            $table->text('svg')->nullable()->comment('svg图标');
            $table->string('color', 7)->default('')->comment('图标背景色');
            $table->unsignedInteger('amount')->default(0)->comment('余额');
            $table->unsignedInteger('quota')->default(0)->comment('额度大于0则是信贷资金');
            $table->string('number', 48)->default('')->comment('卡号 储蓄卡信用卡等');
            $table->string('remark', 128)->default('')->comment('备注');
            $table->unsignedInteger('created_at')->default(0)->comment('创建时间');
            $table->unsignedInteger('updated_at')->default(0)->comment('更新时间');
        });

        // 添加表备注
        DB::statement("ALTER TABLE `property` COMMENT '财产列表'");
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('property');
    }
};